import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.ontology.OntResource;
import com.hp.hpl.jena.rdf.model.InfModel;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.reasoner.Reasoner;
import com.hp.hpl.jena.reasoner.ReasonerRegistry;
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
import com.hp.hpl.jena.vocabulary.RDFS;

public class HelloWorld {
	public static void main(String[] args) {
	//	prueba0();
		//prueba1();
//	prueba3();
//		prueba4();	
		prueba6();
	}
	
	public static void prueba0(){
	    //Code
		Model m = ModelFactory.createDefaultModel();
		String NS ="http://example.com/test/";
		Resource r = m.createResource(NS + "r");
		Property p = m.createProperty(NS + "p");
		
		r.addProperty(p, "Hello World", XSDDatatype.XSDstring);
		
		m.write(System.out, "Turtle");
	}
	public static void prueba1(){
		  String NS = "urn:x-hp-jena:eg/";
		  Model rdfsExample = ModelFactory.createDefaultModel();
		  Property p = rdfsExample.createProperty(NS, "p");
		  Property q = rdfsExample.createProperty(NS, "q");
		  Property r = rdfsExample.createProperty(NS, "r");
		  Property s = rdfsExample.createProperty(NS, "s");
		  rdfsExample.add(p, RDFS.subPropertyOf, q);
		  rdfsExample.add(r, RDFS.subPropertyOf, s);
		  rdfsExample.createResource(NS+"a").addProperty(p, "Propiedad P");
		  rdfsExample.createResource(NS+"a").addProperty(r, "Propiedad R");
		  rdfsExample.createResource(NS+"a").addProperty(s, "Propiedad S");
		  InfModel inf = ModelFactory.createRDFSModel(rdfsExample);
		  Resource a = inf.getResource(NS+"a");
		  System.out.println("Statement: " + a.getProperty(q));
		  System.out.println("Statement: " + a.getProperty(s));
	}
	
	public static void prueba2(){
		Model m = ModelFactory.createDefaultModel();
		InputStream in;
		try {
			in = new FileInputStream("owl/wine.rdf");// or any windows path
			m.read(in, null);
			in.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		Resource r = m.getResource("http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#Rose");
		System.out.println(r.getLocalName());
		System.out.println(r.getNameSpace());
//		m.write(System.out);
		
	}
	
	public static void prueba4(){
		OntologyAccess.loadOntology("owl/test_ontology_20072192_20087293_v1.owl");
		OntologyAccess.printIndividuals("Disease");
		OntologyAccess.printIndividuals("Symptom");				
	}
	
	public static void prueba5(){
		OntologyAccess.loadOntology("owl/test_ontology_20072192_20087293_v2.owl");
		List <String> symptoms = OntologyAccess.getSymptoms("Furunculosis");
		System.out.println("Symptoms of Furunculosis");
		for (String symptom : symptoms) {
			System.out.println(symptom);
		}
		System.out.println("Diseases of Lymphadenopathy");
		List <String> diseases = OntologyAccess.getDiseases("Lesions");
		for (String disease : diseases) {
			System.out.println(disease);
		}
	}
	
	public static void prueba6(){
		OntologyAccess.loadOntology("owl/test_ontology_20072192_20087293_v2.owl");
		List <String> diseases = InferenceEngine.diagnose("Lesions",1);
		for (String disease : diseases) {
			System.out.println(disease);
		}
	}
}
